<?php

namespace App\Http\Controllers\Admin;

use Illuminate\Http\Request;
use DB;
use App\Http\Requests;
use App\Http\Controllers\Controller;

class QuestionController extends Controller
{
    //问题列表
    public function getList(Request $request)
    {

    	//获取显示条数
    	$num=$request->input('num',10);
    	//判断是否有关键字
    	if($request->input('keywords'))
    	{
    		$questions=DB::table('question')
    		->where('question_name','like','%'.$request->input('keywords').'%')
    		->paginate($num);
    	}else
    	{
    		//查询所有用户
    		$questions=DB::table('question')->paginate($num);
    	}
    	//提取所有的参数
    	$data =$request->all();
    	return view('Admin.question.list',['questions'=>$questions,'data'=>$data]);
    }

    //删除
    public function getDelete($id)
    {
    	// dd($id);
    	$res=DB::table('question')->where('id',$id)->delete();
    	if($res)
    	{
    		return back()->with('success','删除成功');
    	}else
    	{
    		return back()->with('error','删除失败');
    	}
    }

  
}
